package cn.iocoder.yudao.module.diy.dal.mysql.diyroute;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.diy.utils.DiyRoutePageReqVO;
import cn.iocoder.yudao.module.diy.dal.diyroute.DiyRouteDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 自定义路由 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface NDiyRouteMapper extends BaseMapperX<DiyRouteDO> {

    default PageResult<DiyRouteDO> selectPage(DiyRoutePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DiyRouteDO>()
                .eqIfPresent(DiyRouteDO::getTitle, reqVO.getTitle())
                .likeIfPresent(DiyRouteDO::getName, reqVO.getName())
                .eqIfPresent(DiyRouteDO::getPage, reqVO.getPage())
                .eqIfPresent(DiyRouteDO::getShare, reqVO.getShare())
                .eqIfPresent(DiyRouteDO::getIsShare, reqVO.getIsShare())
                .eqIfPresent(DiyRouteDO::getSort, reqVO.getSort())
                .orderByDesc(DiyRouteDO::getId));
    }

}